home *** CD-ROM | disk | FTP | other *** search
/ PC Graphics Unleashed / PC Graphics Unleashed.iso / xa / vsa_demo.c < prev    next >
C/C++ Source or Header  |  1994-06-25  |  19KB  |  536 lines

  1. /*..........................................................................*/
  2. /*                              VSA_DEMO.C              6-25-94             */
  3. /*                                                                          */
  4. /*  This is the "C" source code for the VSA_DEMO.EXE program.  This program */
  5. /*  demonstrates the usage of the VSA256 Graphics Library, Version 3.0      */
  6. /*  functions.                                                              */
  7. /*                                                                          */
  8. /*            Note: Set STACK SIZE to approx 10000 bytes.                   */
  9. /*            Note: For BORLAND compilers, use -Fs flag (SS = DS)!          */
  10. /*                                                                          */
  11. /*         Copyright Spyro Gumas, 1992 - 1994.  All Rights Reserved.        */
  12. /*..........................................................................*/
  13.  
  14. #include<dos.h>
  15. #include<stdio.h>
  16. #include<stdlib.h>
  17. #include<math.h>
  18. #include<limits.h>
  19. #include<bios.h>
  20. #include<conio.h>
  21. #include<time.h>
  22.  
  23. #include <vsa.h>            /* Required to support VSA256 Graphics Library  */
  24. #include <vsa_font.h>       /* Required to support VSA256 Graphics Library  */
  25. #include <tiff.h>           /* Required to support TIFF256 Graphics Library */
  26.  
  27. #ifndef _MSC_VER
  28. /*.....                  This is for Borland C Only !                  .....*/
  29. extern unsigned _stklen = 10000;
  30. #endif
  31.  
  32. void cube(int,int,int);
  33. void cubes(int,int,int);
  34. void rainbow_lut(void);
  35. void color_bar(int,int);
  36. void banner(int,int);
  37. void image(int,int);
  38. void obj_3d(int,int);
  39. int  any_key(void);
  40. void delay(unsigned);
  41. void color_effect(void);
  42. void vsa_get_input(char *);
  43.  
  44. float SIN_LUT[1024];
  45.  
  46. void main()
  47. {
  48.     int i,k,l,ty,tx;
  49.     unsigned vmode,xx,yy,a,b,c,d,m,n,oldm,oldn,image_size;
  50.     char your_name[80];
  51.     unsigned char *pict1;
  52.     float x_scale,y_scale;
  53.     srand(1);
  54. /*..........................................................................*/
  55. /*                      Initialize sin look up table.                       */
  56. /*  Index 'i' goes from 0 to 1023 and is equivalent to 0 to 360 degrees.    */
  57. /*..........................................................................*/
  58.     for(i=0;i<1024;i++)
  59.         SIN_LUT[i] = sin(i*6.28/1024.0);
  60. /*..........................................................................*/
  61. /*               Initialize video mode and VSA256 environment.              */
  62. /*               Valid modes are: 100h, 101h, 103h, and 105h.               */
  63. /*..........................................................................*/
  64.     printf("\n");
  65.     printf("Input VESA standard Video Mode (hex)\n");
  66.     printf("(100, 101, 103, or 105): ");
  67.     scanf("%x",&vmode);
  68.     if((i = vsa_init(vmode)) != 0)
  69.         {
  70.             printf("Error Initializing Requested Video Mode!\n");
  71.             if(i==1) printf("  - Did You Load Correct VESA Driver (TSR) ??\n");
  72.             if(i==2) printf("  - VESA BIOS Extensions (Driver) Not Loaded !!\n");
  73.             if(i==3) printf("  - Requested Video Mode Not Supported by this Card!\n");
  74.             if(i==4) printf("  - Mode Not an SVGA Mode Supported by this Card!\n");
  75.             if(i==5) printf("  - VESA Driver Not Returning Mode Information!\n");
  76.             return;
  77.         }
  78.     xx = XResolution;
  79.     yy = YResolution;
  80.     x_scale = XResolution/640.0;
  81.     y_scale = YResolution/480.0;
  82.     vsa_set_text_scale(x_scale,y_scale);
  83.     vsa_set_color(1);
  84.     vsa_move_to(0,0);
  85.     vsa_rect(xx-1,yy-1);
  86. /*..........................................................................*/
  87. /*             Draw color look up table at bottom of screen.                */
  88. /*..........................................................................*/
  89.     rainbow_lut();
  90.     a = .125*xx;
  91.     b = .83*yy;
  92.     color_bar(a,b);
  93. /*..........................................................................*/
  94. /*            Draw "random" cubes enclosed by rectangle                     */
  95. /*..........................................................................*/
  96.     a = .6*xx;
  97.     b = .4*yy;
  98.     c = .88*xx;
  99.     d = .72*yy;
  100.     tx = (a+(c-a)/2) - 12*XCharSize;
  101.     ty = d + 0.01*yy;
  102.     vsa_write_string(tx,ty,250,"Lines using `vsa_line_to'");
  103.     vsa_write_string(tx,ty+YCharSize,64,"Clipping with `vsa_set_viewport'");
  104.     vsa_move_to(a,b);
  105.     vsa_set_color(180);
  106.     vsa_rect(c,d);
  107.     vsa_move_to(a+1,b+1);
  108.     vsa_set_color(20);
  109.     vsa_rect_fill(c-1,d-1);
  110.     vsa_set_viewport(a+1,b+1,c-1,d-1);
  111.     cubes(a,b,1);
  112. /*..........................................................................*/
  113. /*                          Draw a banner                                   */
  114. /*..........................................................................*/
  115.     vsa_set_viewport(0,0,xx,yy);
  116.     a = .55*xx;
  117.     b = .06*yy;
  118.     banner(a,b);
  119. /*..........................................................................*/
  120. /*                    Draw 2D sine-cosine image                             */
  121. /*..........................................................................*/
  122.     a = .08*xx;
  123.     b = .15*yy;
  124.     image(a,b);
  125. /*..........................................................................*/
  126. /*                    Draw a 3-D shaded object                              */
  127. /*..........................................................................*/
  128.     a = .08*xx;
  129.     b = .5*yy;
  130.     obj_3d(a,b);
  131. /*..........................................................................*/
  132. /*                        Using Text Cursor Mode 1.                         */
  133. /*..........................................................................*/
  134.     ty = .05*yy;
  135.     tx = .05*xx;
  136.     vsa_set_text_cursor_mode(1);
  137.     vsa_write_string(tx,ty,250,"Please Enter Your Name: ");
  138.     vsa_get_input(your_name);
  139.  
  140.     vsa_set_text_cursor(tx,ty+YCharSize);
  141.     vsa_set_text_color(200);
  142.     vsa_write_string_alt("Hello ");
  143.     vsa_write_string_alt(your_name);
  144.     vsa_write_string_alt(", Hit any key to bail.");
  145.  
  146. /*..........................................................................*/
  147. /* NOTE: TIFF256 requires Large MEM Model if you uncomment following lines! */
  148. /*..........................................................................*/
  149. /*.....
  150.     printf("Input Full file name for TIFF file to be saved: ");
  151.     scanf("%s",filename);
  152.     tf_save_file(0,YResolution-1,XResolution-1,0,filename);
  153. .....*/
  154. /*..........................................................................*/
  155. /*    Now do moving clipped cubes effect until someone presses a key.       */
  156. /*..........................................................................*/
  157.     k = 0;
  158.     l = 256;
  159.     a = .6*xx;
  160.     b = .4*yy;
  161.     c = .88*xx;
  162.     d = .72*yy;
  163.     oldm = a;
  164.     oldn = b;
  165.     vsa_set_viewport(a+1,b+1,c-1,d-1);
  166.     while(!any_key())
  167.         {
  168.             m = a + xx*0.1*SIN_LUT[k];
  169.             n = b + yy*0.1*SIN_LUT[l];
  170.             vsa_wait_vsync();
  171.             vsa_wait_vsync();
  172.             cubes(oldm,oldn,0);     /* Clear last cube draw */
  173.             cubes(m,n,1);           /* Draw New cubes       */
  174.             k+=4;
  175.             l+=4;
  176.             k=k & 0x3ff;
  177.             l=l & 0x3ff;
  178.             oldm = m;
  179.             oldn = n;
  180.         }
  181.     ty = YResolution/2;
  182.     tx = XResolution/2;
  183. /*..........................................................................*/
  184. /*    Now do sliding blue color effect until someone presses a key.         */
  185. /*..........................................................................*/
  186.     color_effect();
  187. /*..........................................................................*/
  188. /*    Now BitBLTs with vsa_get_image and vsa_put_image                      */
  189. /*..........................................................................*/
  190.     vsa_set_viewport(0,0,xx-1,yy-1);
  191.     i = 0;
  192.     k = 0;
  193.     l = 256;
  194.     a = .30*xx;
  195.     b = .29*yy;
  196.     c = .084*xx;
  197.     d = .11*yy;
  198.     image_size = vsa_image_size(a,b,a+c,b+d);
  199.     if((pict1 = malloc(image_size)) == NULL)
  200.         {
  201.             vsa_write_string(0,0,31,"Error allocating memory for IMAGE");
  202.             getch();
  203.             goto BAIL;
  204.         }
  205.     vsa_get_image(a,b,a+c,b+d,pict1);
  206.     vsa_set_color(0);
  207.     vsa_move_to(a,b);
  208.     vsa_rect(a+c,b+d);
  209.     while(!any_key())
  210.         {
  211.             m = xx/2 + (i)*0.3*SIN_LUT[k];
  212.             n = yy/2 + (i)*0.3*SIN_LUT[l];
  213.             vsa_put_image(m,n,pict1,0);
  214.             k-=4;
  215.             l-=4;
  216.             k=k & 0x3ff;
  217.             l=l & 0x3ff;
  218.             i++;
  219.         }
  220.     free(pict1);
  221.     vsa_set_color(20);
  222.     vsa_move_to(tx-15*XCharSize,ty-2*YCharSize);
  223.     vsa_rect_fill(tx+15*XCharSize,ty+3*YCharSize);
  224.     vsa_write_string(tx-14*XCharSize,ty-YCharSize,200,"BitBlt Using: vsa_image_size");
  225.     vsa_write_string(tx-14*XCharSize,ty          ,200,"              vsa_get_image ");
  226.     vsa_write_string(tx-14*XCharSize,ty+YCharSize,200,"              vsa_put_image ");
  227. /*..........................................................................*/
  228. /*  Now do sliding blue color effect (again) until someone presses a key.   */
  229. /*..........................................................................*/
  230.     color_effect();
  231. /*..........................................................................*/
  232. /*           Restore text video mode and print information.                 */
  233. /*..........................................................................*/
  234. BAIL:
  235.     vsa_set_viewport(0,0,xx-1,yy-1);
  236.     vsa_set_svga_mode(0x3);
  237.     vsa_about();
  238.     getch();
  239.     vsa_init(0x3);
  240.     return;
  241. }
  242.  
  243. void cube(int x,int y,int size)
  244. {
  245.     int sizeb;
  246.     sizeb = size/2;
  247.     vsa_move_to(x,y);
  248.     vsa_rect(x+size,y+size);
  249.     vsa_move_to(x+sizeb,y+sizeb);
  250.     vsa_rect(x+sizeb+size,y+sizeb+size);
  251.     vsa_move_to(x,y);
  252.     vsa_line_to(x+sizeb,y+sizeb);
  253.     vsa_move_to(x+size,y);
  254.     vsa_line_to(x+sizeb+size,y+sizeb);
  255.     vsa_move_to(x+size,y+size);
  256.     vsa_line_to(x+sizeb+size,y+sizeb+size);
  257.     vsa_move_to(x,y+size);
  258.     vsa_line_to(x+sizeb,y+sizeb+size);
  259.     return;
  260. }
  261.  
  262. void cubes(int m,int n,int draw)
  263. {
  264.     int i,x,y,size;
  265.     float xfact,yfact,sfact;
  266.     srand(1);
  267.     vsa_set_color(20);
  268.     xfact = .23*XResolution/(float)RAND_MAX;
  269.     yfact = .23*YResolution/(float)RAND_MAX;
  270.     sfact = .05*xfact/.23;
  271.     for(i=0;i<16;i++)
  272.         {
  273.             x = m+5+xfact*rand();
  274.             y = n+5+yfact*rand();
  275.             size = sfact*rand();
  276.             if(draw)
  277.                 vsa_set_color(i);
  278.             cube(x,y,size);
  279.         }
  280.     return;
  281. }
  282.  
  283. void rainbow_lut()
  284. {
  285.     int i,start,count;
  286.     unsigned char color_array[768];
  287.     for(i=0;i<224;i++)
  288.         {
  289.             color_array[3*i+2]=0;
  290.             color_array[3*i+1]=0;
  291.             color_array[3*i]=0;
  292.         }
  293. /*................................ RED .....................................*/
  294.     for(i=0;i<56;i++)
  295.         {
  296.                 color_array[3*i] = 63*sin((i*6.28)/112.0);
  297.         }
  298. /*............................... BLUE .....................................*/
  299.     for(i=0;i<126;i++)
  300.         {
  301.                 color_array[3*i+2] = 63*sin((i*6.28)/252.0);
  302.         }
  303. /*............................... GREEN ....................................*/
  304.     for(i=96;i<210;i++)
  305.         {
  306.                 color_array[3*i+1] = 63*sin(((i-90)*6.28)/252.0);
  307.         }
  308. /*................................ RED .....................................*/
  309.     for(i=140;i<224;i++)
  310.         {
  311.                 color_array[3*i]   = 63*sin(((i-140)*6.28)/280.0);
  312.         }
  313.     start = 32;
  314.     count = 224;
  315.     vsa_write_color_block(start,count,color_array);
  316.     return;
  317. }
  318.  
  319. void color_bar(x0,y0)
  320. int x0,y0;
  321. {
  322.     int i,ty,tx;
  323.     unsigned xx,yy,a,b;
  324.     float c;
  325.     xx = XResolution;
  326.     yy = YResolution;
  327. /*..........................................................................*/
  328. /*     Draw outline for color bar.                                          */
  329. /*..........................................................................*/
  330.     vsa_set_color(15);
  331.     vsa_move_to(x0-1,y0-1);
  332.     a = .75*xx;
  333.     b = .065*yy;
  334.     vsa_rect(x0+a+1,y0+b+1);
  335.     c = (float)a/256;
  336.     for(i=0;i<256;i++)
  337.         {
  338.             vsa_set_color((unsigned char)i);
  339.             vsa_move_to(x0+(unsigned)(i*c),y0);
  340.             vsa_rect_fill(x0+(unsigned)(c+i*c),y0+b);
  341.         }
  342.     ty = (y0+b+1) + 0.01*YResolution;
  343.     tx = (x0+a/2) - 31*XCharSize;
  344.     vsa_write_string(tx,ty,63,"Color Look Up Table Manipulation using");
  345.     vsa_write_string(tx+38*XCharSize,ty,63," `vsa_write_color_block'");
  346.     vsa_write_string(tx,ty+YCharSize,63,"'vsa_read_color_register' and");
  347.     vsa_write_string(tx+31*XCharSize,ty+YCharSize,63,"`vsa_write_color_register'.");
  348.     return;
  349. }
  350.  
  351. void banner(int x,int y)
  352. {
  353.     int ty,tx;
  354.     unsigned xx,yy,a,b;
  355.     xx = XResolution;
  356.     yy = YResolution;
  357.     a = .40*xx;
  358.     b = .17*yy;
  359.     vsa_move_to(x,y);
  360.     vsa_set_color(1);
  361.     vsa_rect_fill(x+a,y+b);
  362.     vsa_move_to(x+5,y+5);
  363.     vsa_set_color(22);
  364.     vsa_rect_fill(x+a-5,y+b-5);
  365.     tx = (x+5) + 0.08*a;
  366.     ty = (y+6) + 0.15*b;
  367.     vsa_write_string(tx,ty,200,"VSA256 GRAPHICS LIBRARY");
  368.     vsa_write_string(tx,ty+YCharSize,200,"for C Programmers");
  369.     vsa_write_string(tx+18*XCharSize,ty+YCharSize,255,"V3.0");
  370.     vsa_write_string(tx,ty+2*YCharSize,200,"Copyright Spyro Gumas 92-94");
  371.     ty = (y+b) + 0.01*YResolution;
  372.     tx = (x+(a+5)/2) - 16*XCharSize;
  373.     vsa_write_string(tx,ty,2            ,"Text using 'vsa_set_text_scale'  ");
  374.     vsa_write_string(tx,ty+YCharSize,2  ,"           'vsa_write_string'    ");
  375.     vsa_write_string(tx,ty+2*YCharSize,2,"           'vsa_write_string_alt'");
  376.     return;
  377. }
  378.  
  379. void image(int x,int y)
  380. {
  381.     int i,j,ty,tx;
  382.     long ii,jj,z1,z2;
  383.     unsigned char array[1024];
  384.     unsigned xx,yy,a,b;
  385.     xx = XResolution;
  386.     yy = YResolution;
  387.     a = .4*xx;
  388.     b = .26*yy;
  389.     z1 = 2*1024L/a;
  390.     z2 = 1024L/b;
  391.     vsa_move_to(x-2,y-2);
  392.     vsa_set_color(250);
  393.     vsa_rect(x+a+1,y+b+1);
  394.     for(j=0;j<b;j++)
  395.         {
  396.             for(i=0;i<a;i++)
  397.                 {
  398.                     ii = (i*z1) & 0x000003ff;
  399.                     jj = (j*z2+256) & 0x000003ff;
  400. /*.....
  401.                     array[i] = 144+112*sin(i*6.28/c)*cos(j*6.28/c);
  402. .....*/
  403.                     array[i] = 144+112.0*(SIN_LUT[ii]*SIN_LUT[jj]);
  404.                 }
  405.             vsa_raster_line(x,x+a-1,y+j,array);
  406.         }
  407.     ty = (y+b+1) + 0.01*YResolution;
  408.     tx = (x+a/2) - 17*XCharSize;
  409.     vsa_write_string(tx,ty,100,"2D Images Using `vsa_raster_line'");
  410.     return;
  411. }
  412.  
  413. void obj_3d(int x,int y)
  414. {
  415.     int rim1,rim2,tip1,tip2,ty,tx;
  416.     unsigned xx,yy,a,b;
  417.     xx = XResolution;
  418.     yy = YResolution;
  419.     a = .4*xx;
  420.     b = .2*yy;
  421.     vsa_move_to(x-2,y-2);
  422.     vsa_set_color(255);
  423.     vsa_rect(x+a+1,y+b+1);
  424.     vsa_move_to(x,y);
  425.     vsa_set_color(38);
  426.     vsa_rect_fill(x+a,y+b);
  427.     rim1 = 140;
  428.     tip1 = 255;
  429.     tip2 = 32;
  430.     rim2 = 140;
  431. vsa_shaded_triangle((int)(.35*a+x),(int)(.8*b+y),rim1,(int)(.25*a+x),(int)(.8*b+y),rim1,(int)(.9*a+x),(int)(.1*b+y),tip1);
  432. vsa_shaded_triangle((int)(.25*a+x),(int)(.8*b+y),rim1,(int)(.15*a+x),(int)(.6*b+y),rim1,(int)(.9*a+x),(int)(.1*b+y),tip1);
  433. vsa_shaded_triangle((int)(.15*a+x),(int)(.6*b+y),rim1,(int)(.15*a+x),(int)(.4*b+y),rim1,(int)(.9*a+x),(int)(.1*b+y),tip1);
  434. vsa_shaded_triangle((int)(.15*a+x),(int)(.4*b+y),rim1,(int)(.25*a+x),(int)(.2*b+y),rim1,(int)(.9*a+x),(int)(.1*b+y),tip1);
  435. vsa_shaded_triangle((int)(.25*a+x),(int)(.2*b+y),rim1,(int)(.35*a+x),(int)(.2*b+y),rim1,(int)(.9*a+x),(int)(.1*b+y),tip1);
  436. vsa_set_color(32);
  437. vsa_move_to((int)(.3*a+x),(int)(.5*b+y));
  438. vsa_line_to((int)(.9*a+x),(int)(.1*b+y));
  439. vsa_shaded_triangle((int)(.35*a+x),(int)(.2*b+y),rim1,(int)(.45*a+x),(int)(.4*b+y),rim1,(int)(.9*a+x),(int)(.1*b+y),tip1);
  440. vsa_shaded_triangle((int)(.45*a+x),(int)(.4*b+y),rim1,(int)(.45*a+x),(int)(.6*b+y),rim1,(int)(.9*a+x),(int)(.1*b+y),tip1);
  441. vsa_shaded_triangle((int)(.45*a+x),(int)(.6*b+y),rim1,(int)(.35*a+x),(int)(.8*b+y),rim1,(int)(.9*a+x),(int)(.1*b+y),tip1);
  442.  
  443. vsa_shaded_triangle((int)(.80*a+x),(int)(.75*b+y),rim2,(int)(.75*a+x),(int)(.9*b+y),rim2,(int)(.9*a+x),(int)(.1*b+y),tip2);
  444. vsa_shaded_triangle((int)(.75*a+x),(int)(.9*b+y),rim2,(int)(.65*a+x),(int)(.9*b+y),rim2,(int)(.9*a+x),(int)(.1*b+y),tip2);
  445. vsa_shaded_triangle((int)(.65*a+x),(int)(.9*b+y),rim2,(int)(.60*a+x),(int)(.75*b+y),rim2,(int)(.9*a+x),(int)(.1*b+y),tip2);
  446. vsa_shaded_triangle((int)(.60*a+x),(int)(.75*b+y),rim2,(int)(.60*a+x),(int)(.65*b+y),rim2,(int)(.9*a+x),(int)(.1*b+y),tip2);
  447. vsa_shaded_triangle((int)(.60*a+x),(int)(.65*b+y),rim2,(int)(.65*a+x),(int)(.5*b+y),rim2,(int)(.9*a+x),(int)(.1*b+y),tip2);
  448. vsa_set_color(32);
  449. vsa_move_to((int)(.7*a+x),(int)(.7*b+y));
  450. vsa_line_to((int)(.9*a+x),(int)(.1*b+y));
  451. vsa_shaded_triangle((int)(.65*a+x),(int)(.5*b+y),rim2,(int)(.75*a+x),(int)(.5*b+y),rim2,(int)(.9*a+x),(int)(.1*b+y),tip2);
  452. vsa_shaded_triangle((int)(.75*a+x),(int)(.5*b+y),rim2,(int)(.80*a+x),(int)(.65*b+y),rim2,(int)(.9*a+x),(int)(.1*b+y),tip2);
  453. vsa_shaded_triangle((int)(.80*a+x),(int)(.65*b+y),rim2,(int)(.80*a+x),(int)(.75*b+y),rim2,(int)(.9*a+x),(int)(.1*b+y),tip2);
  454.  
  455.     ty = (y+b+1) + 0.01*YResolution;
  456.     tx = (x+a/2) - 19*XCharSize;
  457.     vsa_write_string(tx,ty,14,"3D Objects Using `vsa_shaded_triangle'");
  458.     return;
  459. }
  460.  
  461. void color_effect(void)
  462. {
  463.     int i;
  464.     unsigned char save_color_array[768],j,jj;
  465.     unsigned char red[256],green[256],blue[256];
  466.     vsa_read_color_block(251,5,save_color_array);
  467.     for(j=0;j<5;j++)
  468.         {
  469.             red[j+251]   = save_color_array[3*j];
  470.             green[j+251] = save_color_array[3*j+1];
  471.             blue[j+251]  = save_color_array[3*j+2];
  472.         }
  473.     while(1)
  474.         for(i=32;i<256;i++)
  475.             {
  476.                 vsa_wait_vsync();
  477.                 j = (unsigned char) i;
  478.                 vsa_read_color_register(j,&red[j],&green[j],&blue[j]);
  479.                 vsa_write_color_register(j,0,0,63);
  480.                 if(j <= 36)
  481.                     jj = (unsigned char)(j-37);
  482.                 else
  483.                     jj = (unsigned char)(j-5);
  484.                 vsa_write_color_register(jj,red[jj],green[jj],blue[jj]);
  485.                 if(any_key())
  486.                     return;
  487.             }
  488. }
  489.  
  490. int any_key(void)
  491. {
  492.     int result=0;
  493. #ifdef _MSC_VER
  494. /*.....             For Microsoft C, Use this line.                    .....*/
  495.     if(_bios_keybrd(_KEYBRD_READY))
  496.         result = _bios_keybrd(_KEYBRD_READ);
  497. #else
  498. /*.....             For Borland C, Use this line instead.              .....*/
  499.     if(bioskey(1))
  500.         result = bioskey(0);
  501. #endif
  502.     return result;
  503. }
  504.  
  505. /*.......................... VSA_GET_INPUT .................... 6-25-94 ....*/
  506. /*  This routine reads the keyboard input and echos it to the screen until  */
  507. /* a carriage return is entered. Then the whole text string is returned     */
  508. /* via 'text'.                                                              */
  509. /*..........................................................................*/
  510. void vsa_get_input(char *text)
  511. {
  512.     int i,x,y;
  513.     char key;
  514.     vsa_get_text_cursor(&x,&y);
  515.     i=0;
  516.     text[0] = 0;
  517.     while((key = getch()) != 13)               /*  Do until a return is hit.  */
  518.         {
  519.             if(key != 8)
  520.                 {                                    /*  If not a back space        */
  521.                     text[i] = key;                     /*  add key entry to string.   */
  522.                     text[i+1] = 0;
  523.                     vsa_write_string(x,y,255,text);    /*  Echo the updated string.   */
  524.                     i++;
  525.                 }
  526.             else
  527.                 {                                    /*  If a back space            */
  528.                     if(i > 0) i --;                    /*  delete last key entry.     */
  529.                     text[i] = 92;
  530.                     vsa_write_string(x,y,255,text);    /*  Echo the updated string.   */
  531.                     text[i] = 0;
  532.                 }
  533.         }
  534.     return;
  535. }
  536.